package edu.ntu.im.p2ptrade.msg.handle;

import java.util.HashMap;
import java.util.Map;

import edu.ntu.im.p2ptrade.entity.User;

public class PeerInfoRepository {
	private static PeerInfoRepository me;
	private Map<String, User> peers = new HashMap<String, User>();
	public static PeerInfoRepository getInstance(){
		if (me == null){
			me = new PeerInfoRepository();
		}
		return me;
	}
	public void savePeer(User user){
		System.out.println("add peer:"+user.getName());
		this.peers.put(user.getName(), user);
	}
	public User getPeer(String name){
		return this.peers.get(name);
	}
	public Map<String, User> getAllPeers(){
		return this.peers;
	}
}
